//Accepted
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <iostream>
#include <list>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cstdlib>
using namespace std;

int m, t, u, f, d, i, j , sum, x;
char c[3];
int main (){
	//freopen("in.txt", "r", stdin);//freopen("out.txt", "w", stdout);
	scanf("%d%d%d%d%d", &m, &t, &u, &f, &d);
	f+=f;
	u+=d;
	x=sum=0;
	for(i=0;i<t;++i){
		scanf("%s", c);
		if(c[0]=='f'){
			if(sum+f<=m){
				sum+=f;
				++x;
			}
			else break;
		}
		else {
			if(sum+u<=m){
				sum+=u;
				++x;
			}
			else break;
		}
	}
	printf("%d", x);
	return 0;
}
